package org.miyuki4j.cfgtool.app;

import lombok.extern.slf4j.Slf4j;
import org.miyuki4j.cfgtool.CfgApp;
import org.miyuki4j.cfgtool.CfgAppKeeper;
import org.miyuki4j.cfgtool.Commands;
import org.miyuki4j.cfgtool.RunModeEnum;

/**
 * @Desc
 * @Author miyuki4j
 * @Date 2025/7/28/星期一 17:29
 * @Version 1.0
 */
@Slf4j
public class CommandCfgApp extends CfgApp {
    @Override
    public RunModeEnum runMode() {
        return RunModeEnum.COMMAND;
    }

    @Override
    protected void run() throws Exception {
        String args = String.join(" ", this.args);
        try {
            log.info("开始执行, args:{}", args);
            Commands.run(this.args);
        } catch (Exception e) {
            log.error("执行失败，args:{}", args, e);
        } finally {
            CfgAppKeeper.done();
        }
    }

    @Override
    public void exit() {
        super.exit();
    }
}
